import request from '@/utils/request';

/**
 * 薪资参考数据
 * @param {*}
 */
export async function fetchSalaryReference(param) {
    return request('/api/oa/v1/salarystandard/getpagelist', {
        method: 'POST',
        data: param
    });
}

/**
 * 下载薪资参考模板
 */
export function downTemplate() {
    return request('/api/oa/v1/stream/salarystandard/downtemplate', {
        method: 'GET',
        getResponse: true,
        encryption: false,
        isFile: true,
        responseType: 'blob',
        headers: { 'Content-Type': 'application/json' }
    });
}

/**
 * 下载薪资参考模板微微模板
 */
export function downTemplateVv() {
    return request('/api/oa/v1/stream/vvsalarystandard/downtemplate', {
        method: 'GET',
        getResponse: true,
        encryption: false,
        isFile: true,
        responseType: 'blob',
        headers: { 'Content-Type': 'application/json' }
    });
}

/**
 * 薪资参考数据
 * @param {*}
 */
export async function fetchPostReference(param) {
    return request('/api/oa/v1/salarystandard/getpostmappingpagelist', {
        method: 'POST',
        data: param
    });
}

/**
 * 根据职位id获取相应职位的薪资参考数据
 * @param {*}
 */
export async function getSalaryRef(positionCode) {
    return request(`/api/oa/v2/post/getSalaryStandByPositionCode/${positionCode}`, {
        method: 'GET'
    });
}

/**
 * 下载薪资参考模板
 */
export function downTemplatePost() {
    return request('/api/oa/v1/stream/postmapping/downtemplate', {
        method: 'GET',
        getResponse: true,
        encryption: false,
        isFile: true,
        responseType: 'blob',
        headers: { 'Content-Type': 'application/json' }
    });
}

/**
 * 下载职位映射模板
 */
export function downTemplatePositionMapping() {
    return request('/api/oa/v1/stream/exportPostSalaryInfo', {
        method: 'GET',
        getResponse: true,
        encryption: false,
        isFile: true,
        responseType: 'blob',
        headers: { 'Content-Type': 'application/json' }
    });
}

/**
 * 薪资参考版本记录列表
 * @param {*}
 */
export async function fetchVersionlist() {
    return request('/api/oa/v1/salarystandard/getversionlist', {
        method: 'GET'
    });
}

/**
 * 职位映射版本记录列表
 * @param {*}
 */
export async function fetchPostlist() {
    return request('/api/oa/v1/salarystandard/getpostsalaryversionlist', {
        method: 'GET'
    });
}

/**
 * 薪资参考版本详情
 * @param {*}
 */
export async function fetchVersionDetaillist(param) {
    return request('/api/oa/v1/salarystandard/getsalarystandardhistory', {
        method: 'POST',
        data: param
    });
}
/**
 * 职位参考版本详情
 * @param {*}
 */
export async function fetchPostDetaillist(param) {
    return request('/api/oa/v1/salarystandard/getpostsalaryhistory', {
        method: 'POST',
        data: param
    });
}
/**
 * 上传前检查
 */
export function checkBeforeUpload(data) {
    return request('/api/oa/v1/salarystandard/checkbeforeimportsalary', {
        method: 'POST',
        data
    });
}
/**
 * 上传前检查
 */
export function checkPositionMappingBeforeUpload(data) {
    return request('/api/oa/v1/salarystandard/checkbeforeimportpostmapping', {
        method: 'POST',
        data
    });
}

/**
 * 薪资参考恢复此版本
 * @param {*}
 */
export async function fetchVersionApply(param) {
    return request('/api/oa/v1/salarystandard/salarystandardrollback', {
        method: 'POST',
        data: param
    });
}
/**
 * 职位映射恢复此版本
 * @param {*}
 */
export async function fetchPostApply(param) {
    return request('/api/oa/v1/salarystandard/positionsalaryrollback', {
        method: 'POST',
        data: param
    });
}
